#!usr/lib/perl
use 5.014;
use warnings;
use utf8;

sub total{
	my $totalIs;
	foreach(@_){
		$totalIs += $_;
		}
	$totalIs
	}

sub above_average{
	my $mean = 0;
	my $elements = 0;
	my @result;
	foreach(@_){
		$mean += $_;
		$elements++;
		}
	$mean /= $elements;
	foreach(@_){
		if($_>$mean){
			push @result,  $_ ;
			}
		}
	@result
	}
	
my @fred = qw{ 1 3 5 7 9 };
my $fred_total = total(@fred);
print "The total of \@fred is $fred_total.\n";
print "Enter some numbers on separate lines: ";
my $user_total = total(<STDIN>);
print "The total of those numbers is $user_total.\n";

print "The sum of numbers between 1 and 1000 is ", &total(1..1000), "\n";

my @fred = above_average(1..10);
print "\@fred is @fred\n";
print "(Should be 6 7 8 9 10)\n";
my @barney = above_average(100, 1..10);
print "\@barney is @barney\n";
print "(Should be just 100)\n";
